package com.example.moneygrosService.database;

import android.net.Uri;
import android.provider.BaseColumns;

public class MoneyContract {

	public static final String CONTENT_AUTHORITY = "com.example.moneygrosService";
	public static final Uri BASE_CONTENT_URI = Uri.parse("content://" + CONTENT_AUTHORITY);

	public static final String PATH_BALANCES = "balances";
	public static final String PATH_PENDINGS = "pendings";
	public static final String PATH_USERS = "users";
	public static final String PATH_USER_PROFILES = "user_profiles";

	public static final long UPDATED_NEVER = -2;
	public static final long UPDATED_UNKNOWN = -1;
//
//	public interface SyncColumns {
//		String UPDATED = "updated";
//	}

	interface BalancesColumns {
		String USER_ID = "user_id";
		String BALANCE = "balance";
		String VERSION = "version";
	}
	static public interface UsersColumns {
		String USER_ID = "user_id";
		String BALANCE = "balance";
		String BIDIRECTIONAL = "bidirectional";
		String USER_NAME = "user_name";
		String PHONE_NUMBER = "phone_number";
		String BLUETOOTH_MAC= "bluetooth_mac";
		String VERSION = "version";
	}
	static public interface UserProfilesColumns {
		String USER_ID = "user_id";
		String USER_NAME = "user_name";
		String PHONE_NUMBER = "phone_number";
		String BLUETOOTH_MAC= "bluetooth_mac";
		String VERSION = "version";
	}
	interface PendingsColumns {
		String USER_ID = "user_id";
		String OPERATION_ID = "operation_id";
		String OPERATION_STATUS = "operation_status";
		String OPERATION_DATE = "operation_date";
		String OFFSET = "offset";
		String VERSION = "version";	
	}

	public static class Balances implements BalancesColumns, BaseColumns {

		public static final Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon().appendPath(PATH_BALANCES).build();

		public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.moneygros.balance";
		public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.moneygros.balance";

		public static final String DEFAULT_SORT = BalancesColumns.USER_ID + " ASC";

		public static Uri buildUri(String eventId) {
			return CONTENT_URI.buildUpon().appendPath(eventId).build();
		}

		public static String getId(Uri uri) {
			return uri.getPathSegments().get(1);
		}
	}
	public static class Pendings implements PendingsColumns, BaseColumns {

		public static final Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon().appendPath(PATH_PENDINGS).build();

		public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.moneygros.pending";
		public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.moneygros.pending";

		public static final String DEFAULT_SORT = PendingsColumns.USER_ID + " ASC";

		public static Uri buildUri(String eventId) {
			return CONTENT_URI.buildUpon().appendPath(eventId).build();
		}

		public static String getId(Uri uri) {
			return uri.getPathSegments().get(1);
		}
	}
	public static class Users implements UsersColumns, BaseColumns {
 
		public static final Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon().appendPath(PATH_USERS).build();

		public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.moneygros.user";
		public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.moneygros.user";

		public static final String DEFAULT_SORT = UsersColumns.USER_ID + " ASC";

		public static Uri buildUri(String Id) {
			return CONTENT_URI.buildUpon().appendPath(Id).build();
		}

		public static String getId(Uri uri) {
			return uri.getPathSegments().get(1);
		}
	}
	public static class UserProfiles implements UserProfilesColumns, BaseColumns {
 
		public static final Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon().appendPath(PATH_USER_PROFILES).build();

		public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.moneygros.userprofile";
		public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.moneygros.userprofile";

		public static final String DEFAULT_SORT = UserProfilesColumns.USER_ID + " ASC";

		public static Uri buildUri(String Id) {
			return CONTENT_URI.buildUpon().appendPath(Id).build();
		}

		public static String getId(Uri uri) {
			return uri.getPathSegments().get(1);
		}
	}
//	
//	public interface JoinUsersBalances  {
//        public static final String TABLE = 
//        		PATH_USERS + "JOIN " + PATH_BALANCES
//        		+ " ("+PATH_USERS+"."+UsersColumns.USER_ID
//        		+" = "+PATH_BALANCES+"."+BalancesColumns.USER_ID+")";
//
//        public static final String[] PROJECTION = new String[] {
//        	UsersColumns.USER_NAME,
//            BalancesColumns.BALANCE,
//        	UsersColumns.USER_ID
//        };
//
//        public static final int USER_NAME = 0;
//        public static final int BALANCE = 1;
//        public static final int USER_ID = 2;
//    }
	//
//	interface EventsColumns {
//		String EVENT_ID = "event_id";
//		String EVENT_TITLE = "event_title";
//		String EVENT_DATE = "event_date";
//		String EVENT_TIME = "event_time";
//		String EVENT_TYPE = "event_type";
//		String EVENT_LOCATION = "event_location";
//		String EVENT_ADDRESS = "event_address";
//		String EVENT_PICTURE_URL = "event_picture";
//		String EVENT_DESCRIPTION = "event_description";
//		String EVENT_PRICE = "event_price";
//		String EVENT_LINK = "event_link";
//		String EVENT_PUBLIC_KEY = "event_public_key";
//	}
//
//	interface TicketsColumns {
//		String EVENT_ID = "event_id";
//		String TICKET_ID = "ticket_id";
//		String TICKET_TIMESTAMP = "ticket_timestamp";
//		String EVENT_TITLE = "event_title"; 
//		String TICKET_FIRST_NAME = "ticket_first_name";	
//		String TICKET_LAST_NAME = "ticket_last_name";	
//		String TICKET_EXTRA_INFO = "ticket_extra_info"; 
//		String TICKET_SIGNATURE = "ticket_signature";
//	}

//
//	public static class Events implements EventsColumns, BaseColumns {
//
//		public static final Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon().appendPath(PATH_EVENTS).build();
//
//		public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.eve.event";
//		public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.eve.event";
//
//		public static final String DEFAULT_SORT = EventsColumns.EVENT_DATE + " ASC";
//
//		public static Uri buildEventUri(String eventId) {
//			return CONTENT_URI.buildUpon().appendPath(eventId).build();
//		}
//
//		public static String getEventId(Uri uri) {
//			return uri.getPathSegments().get(1);
//		}
//	}
//	
//	public static class Tickets implements TicketsColumns, BaseColumns {
//
//		public static final Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon().appendPath(PATH_TICKETS).build();
//
//		public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.eve.ticket";
//		public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.eve.ticket";
//
//		public static final String DEFAULT_SORT = TicketsColumns.TICKET_TIMESTAMP + " ASC";
//
//		public static Uri buildTicketUri(String ticketId) {
//			return CONTENT_URI.buildUpon().appendPath(ticketId).build();
//		}
//
//		public static String getTicketId(Uri uri) {
//			return uri.getPathSegments().get(1);
//		}
//	}

}
